<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="./script/rem.js"></script>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/aui-tab.js" ></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
    <script type="text/javascript" src="./script/aui-sharebox.js" ></script>
</head>
<body>

    <header class="head" style="padding-top:0.4rem;">
        <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
        <h3>为他充值</h3>
        <div class="head-r"></div>
    </header>
    <div class="head-d" style="padding-top:0.4rem;"></div>

    <div class="user-invite-recharge">
        您当前赚石
        <p id="integral">0</p>
    </div>

    <ul class="list-input-img mt20">
        <li>
            <img src="image/user-invite-icon-2.png">
            <label>充值赚石：</label>
            <input type="number" id="rechargeIntegral" placeholder="请输入要充值的赚石">
            <p id="level_integral" style="display: none;">100赚石</p>
        </li>
<!--         <li>
            <img src="image/user-invite-icon-1.png">
            <label>支付密码：</label>
            <input type="text" placeholder="请输入支付码">
        </li> -->
    </ul>

    <div class="btn-2 mt60" onclick="recharge();">确定</div>


</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/index.js"></script>
<script type="text/javascript">


    apiready = function(){
        userid = api.pageParam.id;
        level_integral = api.pageParam.level_integral;
        if (level_integral != 0) {
            // alert(level_integral)

            $('#rechargeIntegral').css('display','none');
            $('#level_integral').css('display','block');
            $('#level_integral').html(level_integral+'赚石');
        }
        loadIntegral();
    }

    // 获取当前用户个人赚石
    function loadIntegral(){
        var token = $api.getStorage('token');
        api.ajax({
          url: webAddress + '/api/auth/info',
          method: 'get',
          data: {
            values: {
            },
        },
        headers: {
            Authorization: 'Bearer ' + token,
            Accept: 'application/json',
        },
    },function(ret, err){
      if (ret) {
            // alert( JSON.stringify( ret ) );
            integral = ret.data.integral;
            $('#integral').html(integral);
        } else {
            // alert( JSON.stringify( err ) );
            return false;
        }
    });
    }

    // 确认充值
    function recharge(){
        // 需要支付的赚石
        var needIntegral = 0;

        if (level_integral != 0) {
            needIntegral = level_integral;
        }else{
         needIntegral = $api.byId('rechargeIntegral').value;
         if (needIntegral <= 0) {
            api.toast({
                msg: '请正确填写赚石',
                duration: 2000,
                location: 'bottom'
            });
            return false;
        }
    }

    api.openWin({
        name: 'user_invite_pay_password',
        url: './user_invite_pay_password.html',
        pageParam: {
            id: userid,
            needIntegral: needIntegral,
            integral: integral,
        }
    });
}

function closeWin(){
    api.closeWin({
    });
}

</script>
</html>